package io.a2a.client;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 消息发送参数
 * 用于封装发送给Agent的消息和相关参数
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class MessageSendParams {
    
    private String message;
    private String sessionId;
    private String userId;
    private Long timeout;
    private boolean async = false;
    
    /**
     * 私有构造函数，使用Builder模式创建实例
     */
    private MessageSendParams() {}
    
    /**
     * 获取消息内容
     * @return 消息内容
     */
    public String getMessage() {
        return message;
    }
    
    /**
     * 获取会话ID
     * @return 会话ID
     */
    public String getSessionId() {
        return sessionId;
    }
    
    /**
     * 获取用户ID
     * @return 用户ID
     */
    public String getUserId() {
        return userId;
    }
    
    /**
     * 获取超时时间
     * @return 超时时间（毫秒）
     */
    public Long getTimeout() {
        return timeout;
    }
    
    /**
     * 是否异步调用
     * @return 是否异步
     */
    public boolean isAsync() {
        return async;
    }
    
    /**
     * 创建Builder实例
     * @return Builder实例
     */
    public static Builder builder() {
        return new Builder();
    }
    
    /**
     * Builder类，用于构建MessageSendParams实例
     */
    public static class Builder {
        private final MessageSendParams params = new MessageSendParams();
        
        /**
         * 设置消息内容
         * @param message 消息内容
         * @return Builder实例
         */
        public Builder message(String message) {
            params.message = message;
            return this;
        }
        
        /**
         * 设置会话ID
         * @param sessionId 会话ID
         * @return Builder实例
         */
        public Builder sessionId(String sessionId) {
            params.sessionId = sessionId;
            return this;
        }
        
        /**
         * 设置用户ID
         * @param userId 用户ID
         * @return Builder实例
         */
        public Builder userId(String userId) {
            params.userId = userId;
            return this;
        }
        
        /**
         * 设置超时时间
         * @param timeout 超时时间（毫秒）
         * @return Builder实例
         */
        public Builder timeout(Long timeout) {
            params.timeout = timeout;
            return this;
        }
        
        /**
         * 设置是否异步调用
         * @param async 是否异步
         * @return Builder实例
         */
        public Builder async(boolean async) {
            params.async = async;
            return this;
        }
        
        /**
         * 构建MessageSendParams实例
         * @return MessageSendParams实例
         */
        public MessageSendParams build() {
            if (params.message == null || params.message.trim().isEmpty()) {
                throw new IllegalArgumentException("Message cannot be null or empty");
            }
            return params;
        }
    }
    
    @Override
    public String toString() {
        return "MessageSendParams{" +
                "message='" + message + '\'' +
                ", sessionId='" + sessionId + '\'' +
                ", userId='" + userId + '\'' +
                ", timeout=" + timeout +
                ", async=" + async +
                '}';
    }
}